package top.ezzz.search.model;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

/**
 * @author noear
 * @since 1.0.3
 */
public class EsRanges {

    private final JSONArray oNode;

    public EsRanges(JSONArray oNode) {
        this.oNode = oNode;
    }

    public EsRanges add(Object from, Object to) {
        JSONObject oNode1 = JSONUtil.createObj();
        oNode.add(oNode1);
        if (from != null) {
            oNode1.set("from", from);
        }
        if (to != null) {
            oNode1.set("to", to);
        }

        return this;
    }
}
